<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>{$meta_title}-狂雨小说CMS</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <link rel="stylesheet" href="__ADMIN__/css/font.css">
        <link rel="stylesheet" href="__ADMIN__/css/admin.css">
        <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js"></script>
    </head>
    <body>
    <div class="layui-card layui-card-open">
	    <div class="layui-card-body">
            <form action="{:url('config')}" class="layui-form" method="post">
            	{empty name="custom_config"}
            	{foreach name="data['config']" item="config" key="o_key"}
			        <div class="layui-form-item">
			        	{notempty name="config.title"}
			            <label class="layui-form-label">{$config.title|default=''}</label>
			            {/notempty}
						{switch name="config.type"}
							{case value="text"}
				                <div class="layui-input-block w500">
				                	<input type="text" name="config[{$o_key}]" value="{$config.value}" class="layui-input">
				                	{notempty name="config.tip"}
				                		<div class="layui-form-mid layui-word-aux">{$config.tip}</div>
				                	{/notempty}
				                </div>
				            {/case}
				            {case value="password"}
				              	<div class="layui-input-block w500">
				              		<input type="password" name="config[{$o_key}]" value="{$config.value}" class="layui-input">
				              		{notempty name="config.tip"}
				              			<div class="layui-form-mid layui-word-aux">{$config.tip}</div>
				              		{/notempty}
				              	</div>
							{/case}
							{case value="radio"}
				              	<div class="layui-input-block w500">
				              		{foreach name="config['options']" key="opt_k" item="vo"}
				              			<input type="radio" name="config[{$o_key}]" value="{$opt_k}" title="{$vo}" {eq name="config.value" value="$opt_k"} checked{/eq}>
									{/foreach}
				              		{notempty name="config.tip"}
				              			<div class="layui-form-mid layui-word-aux">{$config.tip}</div>
				              		{/notempty}
				              	</div>
							{/case}
							{case value="checkbox"}
				              	<div class="layui-input-block w500">
				              		{foreach name="config['options']" key="opt_k" item="vo"}
				              			<input type="checkbox" name="config[{$o_key}][]" value="{$opt_k}" title="{$vo}" {eq name="config.value" value="$opt_k"} checked{/eq}>
									{/foreach}
				              		{notempty name="config.tip"}
				              			<div class="layui-form-mid layui-word-aux">{$config.tip}</div>
				              		{/notempty}
				              	</div>
							{/case}
							{case value="select"}
								<div class="layui-input-inline">
									<select name="config[{$o_key}]">
										{foreach name="config['options']" key="opt_k" item="vo"}
											<option value="{$opt_k}" {eq name="config.value" value="$opt_k"}selected{/eq}>{$vo}</option>
										{/foreach}
									</select>
								</div>
								{notempty name="config.tip"}
			              			<div class="layui-form-mid layui-word-aux">{$config.tip}</div>
			              		{/notempty}
							{/case}
							{case value="textarea"}
								<div class="layui-input-block">
				              		<textarea name="config[{$o_key}]" class="layui-textarea">{$config.value}</textarea>
				              		{notempty name="config.tip"}
				              			<div class="layui-form-mid layui-word-aux">{$config.tip}</div>
				              		{/notempty}
				              	</div>
							{/case}
							{case value="copy"}
				              	<div class="layui-input-block w500">
				              		<div class="input-group">
							            <input type="text" name="config[{$o_key}]" id="copy_text_{$o_key}" style="width:436px;" class="layui-input" value="{$config.value}">
							            <button class="layui-btn" data-clipboard-target="#copy_text_{$o_key}" type="button" title="复制">复制</button>
						            </div>
				              		{notempty name="config.tip"}
				              			<div class="layui-form-mid layui-word-aux">{$config.tip}</div>
				              		{/notempty}
				              	</div>
							{/case}
							{case value="hidden"}
								<input type="hidden" name="config[{$o_key}]" value="{$config.value}">
							{/case}
							{case value="picture"}
								<div class="layui-input-block w500">
									<div class="input-group">
										<input type="text" size="52" name="config[{$o_key}]" value="{$config.value}" class="layui-input">
										<button class="layui-btn" id="upload_{$o_key}" type="button">上传图片</button>
									</div>
								</div>
								{notempty name="config.tip"}
			              			<div class="layui-form-mid layui-word-aux">{$config.tip}</div>
			              		{/notempty}
			              		<script type="text/javascript">
									layui.use(['layer','upload','jquery'], function(){
									  var layer = layui.layer;
									  var upload = layui.upload;
									  var uploadInst = upload.render({
									    elem: '#upload_{$o_key}' //绑定元素
									    ,url: '{:url('upload/pic')}' //上传接口
									    ,data: {path:'addons'}
									    ,done: function(data){
									      if(data.code){
									      	layer.msg(data.msg, {icon: 1,shade: 0.3,time: 2000},function(layero, index){
						        					$('[name="config[{$o_key}]"]').val(data.data.path);
						    					});			      	
									      }else{
									      	layer.msg(data.msg, {icon: 0,shade: 0.3});
									      }
									    }
									    ,error: function(){
									      //请求异常回调
									    }
									  });
									});
								</script>
							{/case}
							{case value="group"}
								<div class="layui-tab">
			                        <ul class="layui-tab-title">
			                        	{volist name="config.options" id="li"}
			                            	<li {eq name="i" value="1"}class="layui-this"{/eq}>{$li.title}</li>
			                            {/volist}
			                        </ul>
			                        <div class="layui-tab-content">
			                        	{volist name="config.options" id="tab"}
			                            	<div class="layui-tab-item {eq name="i" value="1"}layui-show{/eq}">
			                            		{foreach name="tab['options']" item="tab_form" key="o_tab_key"}
														<div class="layui-form-item">
												            <label class="layui-form-label">{$tab_form.title|default=''}</label>
															{switch name="tab_form.type"}
																{case value="text"}
													                <div class="layui-input-block w500">
													                	<input type="text" name="config[{$o_tab_key}]" value="{$tab_form.value}" class="layui-input">
													                	{notempty name="tab_form.tip"}
														                	<div class="layui-form-mid layui-word-aux">{$tab_form.tip}</div>
														                {/notempty}
													                </div>
													            {/case}
													            {case value="password"}
													              	<div class="layui-input-block w500">
													              		<input type="password" name="config[{$o_tab_key}]" value="{$tab_form.value}" class="layui-input">
													              		{notempty name="tab_form.tip"}
													              			<div class="layui-form-mid layui-word-aux">{$tab_form.tip}</div>
													              		{/notempty}
													              	</div>
																{/case}
																{case value="radio"}
													              	<div class="layui-input-block w500">
													              		{foreach name="tab_form['options']" key="opt_k" item="vo"}
													              			<input type="radio" name="config[{$o_tab_key}]" value="{$opt_k}" title="{$vo}" {eq name="tab_form.value" value="$opt_k"} checked{/eq}>
																		{/foreach}
													              		{notempty name="tab_form.tip"}
													              			<div class="layui-form-mid layui-word-aux">{$tab_form.tip}</div>
													              		{/notempty}
													              	</div>
																{/case}
																{case value="checkbox"}
													              	<div class="layui-input-block w500">
													              		{foreach name="tab_form['options']" key="opt_k" item="vo"}
													              			<input type="checkbox" name="config[{$o_tab_key}][]" value="{$opt_k}" title="{$vo}" {eq name="tab_form.value" value="$opt_k"} checked{/eq}>
																		{/foreach}
													              		{notempty name="tab_form.tip"}
													              			<div class="layui-form-mid layui-word-aux">{$tab_form.tip}</div>
													              		{/notempty}
													              	</div>
																{/case}
																{case value="select"}
																	<div class="layui-input-inline">
																		<select name="config[{$o_tab_key}]">
																			{foreach name="tab_form['options']" key="opt_k" item="vo"}
																				<option value="{$opt_k}" {eq name="tab_form.value" value="$opt_k"}selected{/eq}>{$vo}</option>
																			{/foreach}
																		</select>
																	</div>
																	{notempty name="tab_form.tip"}
												              			<div class="layui-form-mid layui-word-aux">{$tab_form.tip}</div>
												              		{/notempty}
																{/case}
																{case value="textarea"}
																	<div class="layui-input-block">
													              		<textarea name="config[{$o_tab_key}]" class="layui-textarea" placeholder="{$tab_form.tip}">{$tab_form.value}</textarea>
													              		{notempty name="tab_form.tip"}
													              			<div class="layui-form-mid layui-word-aux">{$tab_form.tip}</div>
													              		{/notempty}
													              	</div>
																{/case}
																{case value="copy"}
													              	<div class="layui-input-block w500">
													              		<div class="input-group">
																            <input type="text" name="config[{$o_tab_key}]" id="copy_text_{$o_tab_key}" style="width:408px;" class="layui-input" value="{$tab_form.value}">
																            <button class="layui-btn" data-clipboard-target="#copy_text_{$o_tab_key}" type="button" title="复制">复制</button>
															            </div>
													              		{notempty name="tab_form.tip"}
													              			<div class="layui-form-mid layui-word-aux">{$tab_form.tip}</div>
													              		{/notempty}
													              	</div>
																{/case}
																{case value="hidden"}
																	<input type="hidden" name="config[{$o_tab_key}]" value="{$tab_form.value}">
																{/case}
																{case value="picture"}
																	<div class="layui-input-block w500">
																		<div class="input-group">
																			<input type="text" size="52" name="config[{$o_tab_key}]" value="{$tab_form.value}" class="layui-input">
																			<button class="layui-btn" id="upload_{$o_tab_key}" type="button">上传图片</button>
																		</div>
																	</div>
																	{notempty name="tab_form.tip"}
												              			<div class="layui-form-mid layui-word-aux">{$tab_form.tip}</div>
												              		{/notempty}
												              		<script type="text/javascript">
																		layui.use(['layer','upload','jquery'], function(){
																		  var layer = layui.layer;
																		  var upload = layui.upload;
																		  var uploadInst = upload.render({
																		    elem: '#upload_{$o_tab_key}' //绑定元素
																		    ,url: '{:url('upload/pic')}' //上传接口
																		    ,data: {path:'addons'}
																		    ,done: function(data){
																		      if(data.code){
																		      	layer.msg(data.msg, {icon: 1,shade: 0.3,time: 2000},function(layero, index){
															        					$('[name="config[{$o_tab_key}]"]').val(data.data.path);
															    					});			      	
																		      }else{
																		      	layer.msg(data.msg, {icon: 0,shade: 0.3});
																		      }
																		    }
																		    ,error: function(){
																		      //请求异常回调
																		    }
																		  });
																		});
																	</script>
																{/case}
															{/switch}
												        </div>
			                            		{/foreach}
			                            	</div>
			                            {/volist}
			                        </div>
			                    </div>
							{/case}
						{/switch}
			        </div>
	            {/foreach}
	            {else/}
					{$custom_config}
				{/empty}
	            <div class="layui-form-item">
	                <div class="layui-input-block">
	                	<input type="hidden" name="id" value="{$Request.param.id}">
	                  	<button class="layui-btn" lay-submit lay-filter="ajax" type="submit">确认保存</button>
	                </div>
              	</div>
            </form>
       	</div>
    </div>
    <script type="text/javascript" src="__STATIC__/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="__STATIC__/clipboard/clipboard.min.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/admin.js"></script>
    </body>
</html>